<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>购物车</title>
<style type="text/css">
table{
	text-align: center;
	line-height: 30px;
	background-color: green;
}

</style>
</head>
<script type="text/javascript">
  var dialog;
	function shop(){
		dialog=window.showModalDialog("address.html","",
			"dialogHeight=300px, dialogwidth=500px;toolbars=0,loction=0,statusbar=1,menubar=0,scrollbars=0");
		var address=dialog.provrnce+dialog.chengshi+dialog.qu+dialog.jiedao+dialog.number1;
		document.all.local.value=address;
	}
	function sb(){

var beee=document.all.local.value;
if (beee=="") {
	alert("请先填写地址");
}
else{
     var a="收货地址为:"+document.all.local.value+"+您本次购买的商品信息如下：\n商品名称：双飞燕键盘\n商品数量：10件\n商品单价：50.5元\n运费：25元\n费用合计：530元\n请确认以上信息是否有误！";
     if (confirm(a)) {
      alert("你确认了收获信息！！！");
     }
     else{
     	alert("你取消了订单！！！");
     }
 }

	}
	function nb(){
	
		var tabone=document.getElementsByTagName("table")[0];
		var tabtwo=document.getElementsByTagName("table")[1]; 
		var mname=document.all.mname.value;
		var unum=document.all.unum.value;
		var fprice=document.all.price.value;
		var yuprice=document.all.yprice.value;
		var total=parseFloat(fprice)*parseInt(unum)+parseFloat(yuprice);
		var	removetd="<input type='button' value='删除' id='pdelete' onclick='premove(this)'/ >";

        var onetr=document.createElement("tr");
        var twotd=document.createElement("td");
         var threetd=document.createElement("td");
          var fourtd=document.createElement("td");
           var fivetd=document.createElement("td");
            var sixtd=document.createElement("td");
             var seventd=document.createElement("td");
             twotd.innerHTML=mname;
             threetd.innerHTML=unum;
             fourtd.innerHTML=fprice;
             fivetd.innerHTML=yuprice;
             sixtd.innerHTML=total;
             seventd.innerHTML=removetd;

             onetr.appendChild(twotd);
             onetr.appendChild(threetd);
             onetr.appendChild(fourtd);
             onetr.appendChild(fivetd);
             onetr.appendChild(sixtd);
             onetr.appendChild(seventd);

             tabone.appendChild(onetr);
             document.getElementById("mname").value="";
             document.getElementById("unum").value="";
             document.getElementById("price").value="";
             document.getElementById("yprice").value="";
	}
	function premove(obj){
		 var row=obj.parentNode;
		 while(row.tagName.toLowerCase()!="tr")
		 {
	        row=row.parentNode;

		}
	if (confirm("请确认是否删除")) {
		row.parentNode.removeChild(row);
	}
}
</script>
<body>
   <table  border="2" cellspacing="0" cellpadding="0" width="600px">
   	<tr>
   		<td colspan="5">商品购物车</td>
   	</tr>
   	<tr>
   		<td>商品名称</td>
   		<td>数量(件)</td>
   		<td>单价(元)</td>
   		<td>运费(元)</td>
   		<td>合计(元)</td>
   		<td>操作</td>
   	</tr>
   	<tr>
   		<td>黑寡妇</td>
   		<td>10</td>
   		<td>288.9</td>
   		<td>20</td>
   		<td>308.9</td>
   		<td><input type="button" id="pdelete" value="删除" onclick="premove(this)"></td>
   	</tr>
   	</table>
   	<table border="2" cellspacing="0" cellpadding="0" width="600px">
   	<tr>
   	<td >名称:<input type="text" id="mname"><br/>
   	数量:<input type="text" id="unum"><br/>
   	单价:<input type="text" id="price"><br/>
   	运费:<input type="text" id="yprice"><br/>
   	<input type="button" name="pop" value="添加" onclick="nb()">
   	</td>

   		<td colspan="5"> 
   		<a href="javascript:shop()">请填写邮寄地址</a>
   		<input type="text" id="local" name="local" /> 
   		<input type="submit" name="sub" id="sub"  onclick="sb()" /> 
   		</td>
   	</tr>
   </table>
   	
</body>
</html>